import flash.display.Sprite;
import flash.display.Stage;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.events.Event;
import flash.text.TextFieldAutoSize;
//import string.Css;
import flash.text.StyleSheet;
import flash.events.TextEvent;



class ErrorMsg extends Sprite {
	
	public function new (msg:String)
	{
		super();
		var title = new TextField();
		title.text = msg;
		
		var format:TextFormat = new TextFormat();
		format.color = 0x000000;
		format.font = "Courier";
		format.size = 10;
		format.align = flash.text.TextFormatAlign.CENTER;
	
		title.setTextFormat(format);
		title.autoSize = flash.text.TextFieldAutoSize.LEFT;
		title.border = true;
		title.x = 5;
		title.y = 5;
		
		this.addChild(title);
	}
	
	public function add_html( html:String ): Void {
		
		var txt:TextField = new TextField();
		
		var style:StyleSheet = new StyleSheet();

		var hover:Dynamic = {};
		hover.fontWeight = "bold";
		hover.color = "#0000FF";
		
		var link:Dynamic = {};
		link.fontWeight = "bold";
		link.textDecoration= "underline";
		link.color = "#0000A0";
		
		var active:Dynamic = {};
		active.fontWeight = "bold";
		active.color = "#0000A0";

		var visited:Dynamic = {};
		visited.fontWeight = "bold";
		visited.color = "#CC0099";
		visited.textDecoration= "underline";

		style.setStyle("a:link", link);
		style.setStyle("a:hover", hover);
		style.setStyle("a:active", active);
		style.setStyle(".visited", visited); //note Flash doesn't support a:visited
		
		txt.styleSheet = style;
		txt.htmlText = html;
		//txt.autoSize = "left";
		txt.autoSize = flash.text.TextFieldAutoSize.LEFT;
		txt.border = true;
		
		var t:TextField = cast( this.getChildAt(0), TextField);
		txt.y = t.y + t.height + 10;
		txt.x = 5;
		
		this.addChild( txt );
		
	}
}
